<?php
namespace app\admin\model;
use think\Model;
use app\admin\model\Areas;
use app\admin\model\BaseModel;
class CloudItems extends BaseModel
{
	public static function getNameAttr($value){
		return $value ? lang($value) : '--';
	}
	public function getCityAttr($value){
		return $value ? lang($value) : '--';
	}
	public function items($page=1,$map=[]){
		return $lists = $this->alias('m')
                ->join('clouds c',"c.id=m.cloud_id")
                ->join('areas a',"a.id = m.city_id")
                ->field('m.*,c.name'.$this->prexLang().' as cloud,a.name'.$this->prexLang().' as city')
                ->where($map)
                ->order('m.country_id asc,m.city_id asc,c.name asc')
                ->paginate(array('list_rows'=>10,'page'=>$page))
                ->toArray();
	}
	/*获取位置id*/
	public static function getLocationId($item_id){
		return self::where(['id'=>$item_id])->value('location_id');
	}
}